<?php

namespace App\Admin\Controllers\Travel;

use App\Models\Travel\Activity;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class ActivityController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '出游活动';

    /**
     * Make a grid builder.
     *列表
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new Activity());
        $grid->header(function ($query) {
            return 'header';
        });
        

        $grid->column('id', __('ID'));
        $grid->column('viewid', __('viewname'));
        $grid->column('money', __('money'));
        $grid->column('venue', __('venue'));
        $grid->column('guide_tel', __('guide_tel'));
        $grid->column('stop_time', __('stop_time'));
        $grid->column('maxnum', __('maxnum'));
        $grid->column('created_at', __('Created at'));
        // $grid->column('updated_at', __('Updated at'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(Activity::findOrFail($id));



        return $show;
    }

    /**
     * Make a form builder.
     *创建
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new Activity());
        // 选择景点  ->options([1 => 'foo', 2 => 'bar', 'val' => 'Option name']);
        $form->select('viewid',__('viewname'))->options('/Admin/Travel/view/viewlist');
        $form->currency('money',__('money'))->symbol('￥');
        $form->text('venue',__('venue'));
        $form->text('guide_tel',__('guide_tel'));
        $form->text('stop_time',__('stop_time'));
        $form->number('maxnum',__('maxnum'))->min(1);
        return $form;
    }
}
